Microprocessors have internal memory to store instructions and data for execution by the microprocessor. Microprocessors can use external memory in some cases, however, accessing external memory by a microprocessor is more time consuming than accessing internal memory. Although internal memory is faster, an amount of internal memory available is usually much smaller than an amount of external memory available to the microprocessor. In some cases, the microprocessor is not allowed to execute out of the external memory.
Memory management support is desirable when a microprocessor's internal memory is smaller than the size of software images containing instructions to be executed. Such memory management should ensure that process units (of the required software images) reside in internal memory when necessary and reside in less expensive memory at other times. For example, when called, process units should be moved from a memory space that cannot be used for execution into an internal memory space that can be used for execution.
The same holds true for operands. There may not be enough room in an internal memory space for the operands needed to execute a task because another process is running in that internal memory space. Thus, when internal memory space limitations such as these occur, the operands are often moved to another accessible memory region. However, at some later time it may be desirable to use the faster internal memory for the operands.
Although a two level memory cache associated with enough memory to store entire software images could help with (or eliminate the need for) memory management, some microprocessors, for example digital signal processors (DSPs) do not always include such a two level memory cache architecture. If the amount of available memory is insufficient to load entire software images, memory management is required.
Although hardware memory management solutions are available, some architectures do not permit use of such hardware. When hardware is not available, one type of memory management has an operating system move whole memory regions at once. A problem with moving the whole memory space is that the memory bus bandwidth will act as a constraint. Additional drawbacks include latency in software and higher power consumption.
Another memory management solution minimizes an amount of memory actually moved from one type of memory to another. In this solution, an executing process is segmented into portions or “bins.” Thus, only some bins and not the whole process can be swapped out to create space for the newly executing process.
Known operating systems that employ this binning concept typically use two operations whenever a process calls a sub-process. The two operations are: 1) load sub-process and 2) run sub-process. In the known run sub-process operation, the kernel portion of the operating system checks the memory to ensure that all bins of the called sub-process are currently resident. The check occurs between loading the sub-process and requesting running of the sub-process, because it is possible that bins of the loaded sub-process have been swapped out. If all bins of the invoked sub-process are not resident, the kernel swaps each non-resident bin into the internal memory, either immediately if nothing else is resident at the target address, or after swapping out any bins currently residing at the target address. The time and resources required to check whether bins are already in memory and then swapping when necessary decreases system performance. In the case where a sub-process is called twice in a row, such checking is a waste of resources.